package com.bdqn.qnnews.wemedia.api.fallback;

import com.bdqn.qnnews.common.base.R;
import com.bdqn.qnnews.wemedia.api.dto.WmUserDto;
import com.bdqn.qnnews.wemedia.api.feign.WeMediaFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author xlzhang
 */
@Component
@Slf4j
public class WeMediaFeignFallback implements FallbackFactory<WeMediaFeignClient> {
    @Override
    public WeMediaFeignClient create(Throwable e) {
        return new WeMediaFeignClient() {
            @Override
            public R<WmUserDto> save(WmUserDto wmUserDto) {
                log.error("参数: {}",wmUserDto);
                log.error("自媒体 save 远程调用出错啦 ~~~ !!!! {} ",e.getMessage());
                throw new RuntimeException("自媒体 save 远程调用出错啦 ~~~ !!!! " + e.getMessage());
            }

            @Override
            public R<WmUserDto> findByName(String name) {
                log.error("参数: {}",name);
                log.error("自媒体 findByName 远程调用出错啦 ~~~ !!!! {}",e.getMessage());
                throw new RuntimeException("自媒体 findByName 远程调用出错啦 ~~~ !!!! " + e.getMessage());
            }
        };
    }
}